﻿<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="function.jsp"%>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>标签管理</title>
	<link rel="stylesheet" href="/css/public.css?cache=<%=Math.random()%>">
	<link  href="../../hos_manage/images/favicon.ico?cache=<%=Math.random()%>" rel="shortcut icon" type="image/x-icon">
	<link rel="stylesheet" type="text/css" href="../../css/palace/tag/tag_manage.css?a=<%=Math.random()%>">
	<script src="/js/jquery-1.9.1.min.js"></script>
</head>
<body id="app" v-cloak>
<%@ include file="../../header.jsp"%>
<!--内容-->
<div class="containerone">
	<%@ include file="../../left_menu.jsp"%>
	<!--右边内容-->
	<div class="right_cont">
		<!--右边导航下面内容-->
		<div class="tag-manage">
			<div class="title">
				<div class="address-left show-block note">
					<span class="hover" @click="homePage()">首页</span>
					<span class="left-distance">></span>
					<span class="left-distance">标签列表</span>
				</div>
				<div class="create-member" @click="addTag()">新建扩展标签</div>
			</div>
			<div class="container">
				<div class="position">
					<div class="show-block address-book-right">
						<div class="all-operate create">
							<div class="basic">基础标签</div>
						</div>
						<div>
							<div class="zc show-block show-margin-left same" v-for="i in basic" @click="subList(i)" v-html="i.name"></div>
						</div>
						<div class="all-operate create" style="margin-top: 3%">
							<div class="basic">扩展标签</div>
						</div>
						<div class="data-form show-margin-left line">
							<div class="form-title">
								<div class="show-block title-width">名称</div>
								<div class="show-block title-width">备注</div>
								<div class="show-block title-width">操作</div>
							</div>
							<div class="form-title bg-white line" @click="extendDetail(i)" v-for="i in extend">
								<div class="show-block title-width" v-html="i.name"></div>
								<div class="show-block title-width" v-html="i.alias"></div>
								<div class="show-block title-width">
									<img src="../../images/palace/tag/edit.png" @click="editTag(i)">
									<img class="delete" src="../../images/palace/tag/del.png" @click="deleteTag(i)">
								</div>
							</div>
						</div>
						<pagination :pagecount="page_count" :currentpage="current_page"></pagination>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<edittag v-if="editTagShow" :name="tagName" :remark="tagRemark" :id="tagId"></edittag>
<addtag v-if="addTagShow"></addtag>
<delete v-if="deleteShow" :top="delete.top" :title="delete.title" :content="delete.content" :arg="delete.arg"></delete>
<danger v-if="dangerTipShow" :title="dangerTitle"></danger>
<message v-if="messageTipShow" :title="messageTitle"></message>
</body>
<%@ include file="/components/danger.jsp"%>
<%@ include file="/components/tag/edit_tag.jsp"%>
<%@ include file="/components/tag/add_tag.jsp"%>
<%@ include file="/components/delete.jsp"%>
<%@ include file="/components/message.jsp"%>
<%@ include file="/components/pagination.jsp"%>
<script type="text/javascript">
    new Vue({
        el: "#app",
        data: {
            editTagShow: false,
            addTagShow: false,
            deleteShow: false,
            dangerTitle: "",
            dangerTipShow: false,
            messageTitle: "",
            messageTipShow: false,
			basic: [],
			extend: [],
            page_count: 0,
            current_page: 1,
            tagName: "",
            tagRemark: "",
            tagId: 0,
			delete: {
                top: "",
				title: "",
				content: "",
				arg: {},
			}
        },
        methods: {
            // 编辑标签
            editTag: function(i) {
                this.tagName = i.name;
                this.tagRemark = i.alias;
                this.tagId = i.id;
                this.editTagShow = true;
                event.stopPropagation();
            },
            // 添加标签
            addTag: function () {
                this.addTagShow = true;
            },
            homePage: function () {
				location.href = "../../index.jsp";
            },
			deleteTag: function(tag) {
                var _this = this;
                this.deleteShow = true;
                this.delete.top = "删除扩展标签";
                this.delete.title = "确定删除扩展标签";
                this.delete.content = "只是删除此标签，不会影响标签内成员";
                this.delete.arg = function() {
                    $.ajax({
                        type: 'POST',
                        url: "tag_manage.jsp",
                        data: {
                            act: "tagDel",
                            hospital: HOSPITAL,
                            tag_id: tag.id + "",
                        },
                        success: function(res) {
                            res = JSON.parse(res);
                            if (res.errcode == 0) {
                                _this.messageTitle = "标签删除成功";
                                _this.messageTipShow = true;
                                _this.getTag();
                            } else {
                                _this.dangerTitle = res.errmsg;
                                _this.dangerTipShow = true;
                            }
                        },
                    });
				}
                event.stopPropagation();
			},
			// 标签详情
            extendDetail: function(tag) {
                saveParmsHerf("tag_manage", {
                    current_page: this.current_page,
				});
                locationHerf("tag_detail", tag);
			},
			subList: function(tag) {
                saveParmsHerf("tag_manage", {
                    current_page: this.current_page,
                });
                locationHerf("sub_list", tag);
			},
			getTag: function() {
                var _this = this;
                $.ajax({
                    type: 'POST',
                    url: "tag_manage.jsp",
                    data: {
                        act: "tagQuery",
                        hospital: HOSPITAL,
                        page_num: this.current_page + "",
                    },
                    success: function(res) {
                        res = JSON.parse(res);
                        if (res.errcode == 0) {
                            _this.page_count = res.data.total_page;
                            _this.basic = res.data.basic;
                            _this.extend = res.data.extend;
                            if (_this.extend.length == 0 && _this.current_page != 1) {
                                _this.current_page --;
                                _this.getTag();
							}
                        } else {
                            _this.dangerTitle = res.errmsg;
                            _this.dangerTipShow = true;
                        }
                    },
                });
			},
        },
        events: {
            // 关闭添加成员
            closeEditTagShow: function() {
                this.editTagShow = false;
            },
            closeAddTagShow: function() {
                this.addTagShow = false;
            },
			// 标签添加成功
            addTagSuccess: function () {
                this.addTagShow = false;
                this.current_page = 1;
                this.getTag();
            },
			editTagSuccess: function() {
                this.editTagShow = false;
                this.getTag();
			},
            deleteCancel: function() {
                this.deleteShow = false;
            },
			deleteSuccess: function(arg) {
                var _this = this;
                this.deleteShow = true;
                this.delete = arg;
			},
            danger: function(title) {
                this.dangerTitle = title;
                this.dangerTipShow = true;
            },
            dangerTipOver: function() {
                this.dangerTipShow = false;
            },
            message: function(title) {
                this.messageTitle = title;
                this.messageTipShow = true;
            },
			// 消息消失的方法,
            messageTipOver: function() {
                this.messageTipShow = false;
            },
			// 分页所触发的方法
            changePage: function(i) {
                this.current_page = i.currentpage;
                this.getTag();
            },
        },
		ready: function() {
            var parms = getHrefParms("tag_manage");
            if (parms) {
                this.current_page = parms.current_page;
                clearHrefParms("tag_manage");
			}
            this.getTag();
		},
        components: {
            edittag: editTag,
            addtag: addTag,
            delete: deleteTip,
            danger: dangerTip,
            message: messageTip,
            pagination: pagination,
        }
    });
</script>
</html>